package com.globallogic.vkulyk.SSHTool;

import org.junit.*;
import java.io.*;

public class E2E_UserDataMode_PutFile extends SSHToolTester {

	@Before
	public void setup() {
		setVarsFromPropertiesFile("testData/testing.properties");
	}

	@Test
	public void shouldPutFile() {
		String fileName = new File(srcFileForPut).getName();
		String dstFile = dstDirForPut + "/" + fileName;
		new CommandExecutor(host, port, user, password, "rm -f " + dstFile)
				.execute();
		ByteArrayOutputStream outActual = new ByteArrayOutputStream();
		System.setOut(new PrintStream(outActual));
		String[] args = { user + ":" + password + "@" + host + ":" + port,
				"-put", srcFileForPut, dstDirForPut };
		String outExpected = dstFile;

		new CLIHandler().run(args);

		new CommandExecutor(host, port, user, password, "ls " + dstFile)
				.execute();
		String outActualWithRemovedNewLine = outActual.toString().replaceAll(
				"\\n", "");
		Assert.assertEquals("Output not equals, file not found remotely ",
				outExpected, outActualWithRemovedNewLine);

		System.setOut(null);
	}

}